package com.ymatou.app.testcase;

import java.util.ArrayList;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.app.parameter.LiveProductIdsBean;
import com.ymatou.app.parameter.ScartprodBean;
import com.ymatou.app.service.LiveProductIdsCall;
import com.ymatou.app.service.ScartprodCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.SellerCallService;

public class Ts_Scartprod {
	
	private static ScartprodBean scartprodBean = null;
	private static ScartprodCall scartprodCall = null;
	private static SellerCallService sellerCallService = null;
	private int activityId = 0;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品列表接口");
		sellerCallService = new SellerCallService("zhangyi_seller002", "123456");
	}

	@Before
	public void caseUp() {
		scartprodCall = new ScartprodCall();
		scartprodBean = new ScartprodBean();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(scartprodCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_LiveProductIds_001() {
		Logger.start(true,"验证添加购物车是否成功");
		try {
			Logger.comment("创建直播");
			sellerCallService.createActivity();
			
			activityId = sellerCallService.getActivityInProgress();
			
			Logger.comment("添加三个商品");
			sellerCallService.createProduct(activityId, 3);
			
			Thread thread = Thread.currentThread();
			thread.sleep(15000);
			
			Logger.comment("直播验证");
			//scartprodBean.setCatalogid(catalogid);
			scartprodBean.setPurchasenum(1);
			
			scartprodCall.setData(scartprodBean);
			scartprodCall.callService();		
			Logger.comment("activityCall send:" + scartprodCall.getEntityString());
			Logger.comment("activityCall response:" + scartprodCall.getReturnData());
			
			Logger.verifyEquals("true", scartprodCall.getResult().get("success"), "验证添加购物车是否成功");	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
